﻿@{
ViewData["Title"] = "用户信息";
Layout = "_Layout";
}
<div class="row">
    <div style="margin-top:10px;" class="fifteen wide column">
        <div class="ui fluid card">
            <div class="content">
                <h3><i class="user icon"></i>更改用户信息</h3>
            </div>
            <div class="extra content">
                <div style="margin-top:10px;" class="fifteen wide column">
                    <div class="ui form" id="form1">
                        <div class="two fields">
                            <div class="field">
                                <label>用户名：</label>
                                <input type="text" name="inputName" disabled value="@ViewBag.UserInfo.UserName">
                            </div>
                            <div class="field">
                                <label>密码：<span style="color:#999;font-weight:normal;">(最长15位,留空不改变)</span></label>
                                <input type="password" maxlength="15" name="inputPass">
                            </div>
                        </div>
                        <!--<div class="field">-->
                        <!--<label>用户等级：</label>-->
                        <!--<select name="selectLevel" class="ui fluid dropdown">-->
                        <!--<option value="1">普通用户</option>-->
                        <!--<option value="2">管理员</option>-->
                        <!--</select>-->
                        <!--</div>-->
                        <div class="field">
                            <label>邮箱地址：</label>
                            <input type="text" name="inputEmail" value="@ViewBag.UserInfo.Email">
                        </div>
                        <div class="field">
                            <label>手机号：</label>
                            <input type="text" maxlength="11" name="inputMobile" value="@ViewBag.UserInfo.Mobile">
                        </div>
                        <!--<div class="field">-->
                        <!--<div class="ui toggle checkbox" name="cboxStatus">-->
                        <!--<input type="checkbox" name="inputStatus" class="hidden">-->
                        <!--<label>启用/停用</label>-->
                        <!--</div>-->
                        <!--</div>-->
                        <input type="hidden" name="inputId" value="@ViewBag.UserInfo.Id">
                        <button class="ui fluid blue submit button"><i class="save icon"></i>保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/js/jquery.sha1.js"></script>
<script>
    $(function () {
        // $("select[name='selectLevel']").dropdown("set selected", "@ViewBag.UserInfo.Level");
        // var status = parseInt("@ViewBag.UserInfo.Status") == 1 ? "check" : "uncheck";
        // $("div[name='cboxStatus']").checkbox(status);
        $("#form1").form({
            fields: {
                inputName: {
                    identifier: "inputName",
                    rules: [{type: "empty", prompt: "用户名不得为空"}]
                },
                inputEmail: {
                    identifier: "inputEmail",
                    rules: [{type: "email", prompt: "邮箱格式不正确"}]
                }
            },
            inline: true,
            onSuccess: function (event, fields) {
                var loading = layer.load(1);
                var passWord = $("input[name='inputPass']").val();
                if (!Tools.isEmpty(passWord)) {
                    fields['inputPass'] = $.encoding.digests.hexSha1Str(passWord);
                }
                $.post("/User/InfoDo", fields, function (data) {
                    layer.close(loading);
                    if (data["code"] > 0) {
                        layer.msg(data["msg"], {icon: 2});
                        return false;
                    }
                    layer.msg("信息更新成功，需要重新登录", {icon: 1, time: 1500}, function () {
                        window.location.href = "/Login";
                    });
                });
            }
        });
    });

</script>